[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

[Week2] - JavaScript :邏輯 & 位元運算子

[Week2] - JavaScript :邏輯 & 位元運算子

Leetcode 刷題 pattern - Two Pointer

Leetcode 刷題 pattern - Two Pointer

Angular 9 SCSS Global Variable

Angular 9 SCSS Global Variable






留言討論